<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('城市列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" th:attr="data-id=${parentId}"  onclick="add(this)" shiro:hasPermission="system:role:add">
                <i class="fa fa-plus"></i> 新增
            </a>

        </div>

        <div class="col-sm-12 search-collapse">
            <form id="role-form">
                <div class="select-list">
                    <ul>
                        <li>
                            <h3 th:utext="${title}"></h3>
                        </li>
                    </ul>
                </div>
            </form>
        </div>



        <div class="col-sm-12 select-table table-striped">

            <div class="col-sm-2" style="padding: 5px 0;" th:each="item,cstatus: ${areaList}">
                <input type="hidden" name="areaId" th:value="${item.areaId}">

                <a href="javascript:;" onclick="openCity(this)"  th:attr="data-open=${open}">
                  <h3   th:text="${item.areaName}"></h3>
                </a>
                <a class="btn btn-primary btn-sm"  onclick="edit(this)" role="button">修改</a>
            </div>

        </div>
    </div>
</div>



<th:block th:include="include :: footer" />

<script th:inline="javascript">
    //这个代码会被java的thymeleaf编译成文字
    var editFlag = [[ ${@permission.hasPermi('system:role:edit')}]];

    var prefix = ctx + "admin/area";


    //修改按钮
    function edit(that){
       var areaId= $(that).parent().find("input[name='areaId']").val();
       console.log(areaId);
       $.modal.open("修改信息", prefix+"/edit/"+areaId);
    }

    //点击显示下级列表
    function openCity(that){
        var areaId= $(that).parent().find("input[name='areaId']").val();
        var open=$(that).attr("data-open");
        if(open=='1'){
            var url=prefix+'/list/'+areaId;
            window.location.href=url;
        }
    }

    //新增按钮
    function add(that){
        var parentId=$(that).attr("data-id");
        $.modal.open("添加", prefix+"/add/"+parentId);
    }


</script>




</body>
</html>